﻿namespace MultiService;

/// <summary>
/// 模拟一个后台服务
/// </summary>
public class BackService : BackgroundService
{
    private readonly IWebHostEnvironment _env;

    public BackService(IWebHostEnvironment env)
    {
        _env = env;
    }
    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        await Task.Run(() =>
        {
            while (true)
            {
                Console.WriteLine($"后台服务 ->  {DateTime.Now:yyyy-MM-dd HH:mm:ss}");
                Thread.Sleep(3000);
            }
        }, stoppingToken);
        //await Task.CompletedTask;
    }
}
